home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PRINTER / NEWPRT10.ARJ / GRAFPRNT.HPP < prev    next >
C/C++ Source or Header  |  1991-12-13  |  4KB  |  142 lines

  1.  
  2.  
  3. //parent class of all the various printer types. contains
  4. //code and variables common to all types
  5. class graphics_printer
  6. {
  7. public:
  8.     static void set_printer_type(int type)
  9.     {
  10.         printer_type = type;
  11.     }
  12.  
  13.     static void set_printer_port(char * port = "lpt1") //default lpt1
  14.     {
  15.         strcpy(printer_port, port);
  16.     }
  17.  
  18.     //currently this doesnt do anything, the image size is
  19.     //fixed at about 6.4 inches by 4 inches for a
  20.     //640 by 400 pixel image, but it would be a nice feature...
  21.     static void set_print_size(float width, float height)
  22.     {
  23.         image_width = width;
  24.         image_height = height;
  25.     }
  26.     //figures out what kind of printer object to be and
  27.     //returns a pointer to that object
  28.     static void * allocate_graphics_printer(int pixels_per_line);
  29.  
  30.     virtual void print_grey_line(char * buffer, int buffer_length);
  31.  
  32.     //make this virtual so we can reach it through a pointer
  33.     virtual void deallocate_graphics_printer()
  34.     {
  35.     }
  36.  
  37. protected:
  38.     //data portion of the object
  39.     static int printer_type;
  40.     static char printer_port[20];
  41.     static int port_handle;
  42.     static int image_width;   //the size of the final printed image
  43.     static int image_height;
  44.  
  45.     //pointer to the input grey line info
  46.     char * grey_line_buffer;
  47.     int grey_line_count;
  48.  
  49.     int expansion_factor_x;  //expansion factors for expanding
  50.     int expansion_factor_y;  //the grey information
  51.     int len_expanded_lines;  //the expanded line length
  52.     char *expansion_buffer[4]; //4 is the maximum expected expansion
  53.  
  54.     unsigned char *dither_buffer[2]; //only dither a max of three lines at a time
  55.     unsigned char *completed_dither_buffer; //storage for completed line after dither
  56.     unsigned char *bits_buffer; //storage for one bit per pixel output
  57.  
  58.  
  59.     void expand_grey_line();  //generic expansion
  60.  
  61.  
  62.     void dither_expanded_line(int line_number);
  63.     void convert_dithered_line_to_bits(void);
  64.     virtual void bits_to_printer(void);
  65.  
  66.  
  67.     void send_print_buffer(char * line_buffer, int length);
  68.  
  69.     void line_feed();
  70.     virtual void open_graphics_printer()
  71.     {
  72.     }
  73.     virtual void close_graphics_printer()
  74.     {
  75.     }
  76.  
  77.     int serpentine; //flag for which way to scan the dither
  78. };
  79.  
  80.  
  81. //derived class from the above, depending on the printer type
  82. class epson_24_graphics_printer:graphics_printer
  83. {
  84.    //give it a constructor for setting up various things
  85.    //pass it the line length so it can alloc the buffers
  86. public:
  87.     epson_24_graphics_printer(int pixels_per_line);
  88.  
  89.     //make the destructor accessible from a pointer
  90.     virtual void deallocate_graphics_printer(void);
  91.  
  92.  
  93. protected:
  94.  
  95.     //methods (protected)
  96.  
  97.     virtual void bits_to_printer(void);
  98.     void line_feed();
  99.     void send_graphics_buffer(char * line_buffer, int length);
  100.     virtual void open_graphics_printer(void);
  101.     virtual void close_graphics_printer(void);
  102.  
  103.     //The printer buffer that will be shipped out to the printer
  104.     char *printer_buffer;
  105.  
  106.     int pin_number;  //keeps track of which pin we're on
  107.  
  108. };
  109.  
  110.  
  111. //derived class from the above, depending on the printer type
  112. class hp_laser_graphics_printer:graphics_printer
  113. {
  114.    //give it a constructor for setting up various things
  115.    //pass it the line length so it can alloc the buffers
  116. public:
  117.     hp_laser_graphics_printer(int pixels_per_line);
  118.  
  119.     //make the destructor accessible from a pointer
  120.     virtual void deallocate_graphics_printer(void);
  121.  
  122.  
  123. protected:
  124.  
  125.     //methods (protected)
  126.  
  127.     virtual void bits_to_printer(void);
  128.     void line_feed();
  129.     void send_graphics_buffer(unsigned char * line_buffer, int length);
  130.     virtual void open_graphics_printer(void);
  131.     virtual void close_graphics_printer(void);
  132.  
  133.     //The printer buffer that will be shipped out to the printer
  134.     char *printer_buffer;
  135.  
  136.     int pin_number;  //keeps track of which pin we're on
  137.  
  138. };
  139.  
  140.  
  141.  
  142.